export function toString(binaryData) {
    // 创建一个 TextDecoder 对象，指定字符编码为 UTF-8
    const decoder = new TextDecoder('utf-8')
  
    // 将二进制数据解码为字符串
    const stringValue = decoder.decode(binaryData)
    console.log("stringValue:",stringValue)
    const messages = parseConcatenatedJSON(stringValue);
    let messageStr = ""
    messages.forEach(element => {
      messageStr+= element.msg
    });
    return messageStr
  
  }
  export function parseConcatenatedJSON(concatenatedString) {
    let result = [];
    
    // 匹配连续的 JSON 对象，并将其解析存入结果数组
    const matches = concatenatedString.split("||");
    
    if (matches) {
        result = matches.filter(item => item).map(match => {
          return JSON.parse(match)
        });
    }
    
    return result;
  }